Repository navigation
fix(auth): harden MFA and session lifecycle - #284
NeerajCodz wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@codex review |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aafdb1e6eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .filter((q) => | ||
| q.and(q.neq(q.field('_id'), current._id), q.eq(q.field('deletedAt'), undefined)), | ||
| ) | ||
| .paginate({ numItems: GROUP_PROFILE_SEARCH_PAGE_SIZE, cursor }); |
There was a problem hiding this comment.
Replace the repeated paginated scan
When more than 50 matching users must be inspected before finding 20 discoverable profiles, this loop invokes .paginate() a second time and the production query throws instead of returning suggestions. Convex permits only one paginated call per query; its pagination documentation explicitly notes that the second call raises an exception, so this scan needs a non-paginated bounded approach or separate query invocations.
Useful? React with 👍 / 👎.
| next === 'active' && | ||
| userId && | ||
| backgroundAt.current !== null | ||
| ) { |
There was a problem hiding this comment.
Clear the background timestamp while signed out
If the app is backgrounded and restored while userId is null, this condition skips the only statement that clears backgroundAt. After the user signs in, a later inactive → active transition—such as opening and dismissing a system overlay—uses that stale pre-sign-in timestamp and can immediately relock the returning user's app or invalidate an in-flight device unlock. Clear the timestamp whenever the app becomes active, while applying the timeout only when a user is present.
Useful? React with 👍 / 👎.
| await sendTwoFactorEmail(email, code); | ||
| } catch (error) { | ||
| await ctx.runMutation(internal.authEmailChallenges.revoke, { challengeIdHash }); |
There was a problem hiding this comment.
Keep TOTP sign-in independent of email delivery
When the email provider is unavailable, this awaited fallback send throws and the catch revokes the challenge before a TOTP-enabled user receives its ID. The previous TOTP path created a challenge without sending email, so this change makes authenticator and recovery-code sign-in unavailable during any email outage even though neither method needs email; for accounts with those factors, keep the fallback send best-effort or still return a usable challenge when delivery fails.
Useful? React with 👍 / 👎.
| .query('sessionDevices') | ||
| .withIndex('by_user', (q) => q.eq('userId', user._id)) | ||
| .filter((q) => q.neq(q.field('sessionId'), sessionId)) | ||
| .first(); | ||
| if (priorDevice && (await privacyFor(ctx, user._id)).signInAlerts) |
There was a problem hiding this comment.
Fall back to active sessions for sign-in alerts
When another valid session has not yet created a sessionDevices row—such as an older client or a client whose best-effort touchSession call failed—priorDevice is null and this new sign-in produces no security alert. The client hooks swallow touch failures, and mobile does not retry, whereas the replaced authSessions predicate detected this case; retain the historical-device check but also treat another active session as prior account use.
Useful? React with 👍 / 👎.
| ['Pixel 8', 'android', false], | ||
| ]); | ||
| const alerts = await t.run((ctx) => ctx.db.query('notifications').collect()); | ||
| expect(alerts.map((row) => [row.type, row.title])).toEqual([ |
There was a problem hiding this comment.
Restore the missing alerts lookup in the device test
This test now references alerts without declaring it because the query that initialized the variable was removed. Whenever test:web reaches this case, Vitest throws ReferenceError: alerts is not defined before evaluating the updated expectations, so the test suite cannot pass.
Useful? React with 👍 / 👎.
- Bound username-search candidates while retaining privacy filtering. - Restore the notification fixture used by the security assertion.
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
- Query the fixture notifications using the seeded user id.
Changes
Issues
Fixes #264
Fixes #265
Fixes #266
Fixes #273
Fixes #274
Fixes #275
Fixes #276
Fixes #277
Fixes #278